package leetcode.editor.cn;

/**
 * @author: yangwk
 * @date: 2023/6/6
 * @description:
 **/
public class P509FibonacciNumber {
    public static void main(String[] args) {
        System.out.println(fib(3));
    }
    public static int fib(int n) {
        if (n == 0) {
            return 0;
        }
        if (n == 1 || n == 2) {
            return 1;
        }
        int[] arr = new int[n+1];
        arr[1] = 1;
        arr[2] = 1;
        for (int i = 3; i <=n; i++) {
            arr[i] = arr[i - 1] + arr[i-2];
        }
        return arr[n];
    }
}
